package com.wf.userManagement.controller;

import com.wf.apicommons.entity.userManagement.UserInformation;
import com.wf.apicommons.utils.CommonResult;
import com.wf.apicommons.utils.JWTUtils;
import com.wf.apicommons.utils.SnowflakeUtil;
import com.wf.userManagement.mapper.UserInformationMapper;
import com.wf.userManagement.service.local.UserRelatedService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/user")
@Slf4j
public class UserRelatedController {



    @Autowired
    @Qualifier("userRelatedServiceImpl")
    UserRelatedService urs;


    /**
     * 登录
     * @param userInformation
     * @return
     */
    @PostMapping(value = "/login")
    public CommonResult<String>  login(@RequestBody UserInformation userInformation)
    {
        return urs.userLogin(userInformation);
    }


    /**
     * 用户注册
     * @param userInformation
     * @return
     */
    @PostMapping(value = "/register")
    public CommonResult<String>  register (@RequestBody UserInformation userInformation)
    {
        return urs.userRegister(userInformation);
    }


    /**
     * 获取验证码
     * @param phoneNumber
     * @return
     */
    @GetMapping(value = "/getCode/{phoneNumber}")
    public CommonResult<String> getCode (@PathVariable String phoneNumber){
        return urs.getVerificationCode(phoneNumber);
    }


    /**
     * 校验token
     * @return
     */
    @GetMapping(value = "/check")
    public CommonResult<String> checkToken (){
        return CommonResult.success("成功");
    }


    /**
     * 获取用户详细信息
     * @return
     */
    @GetMapping(value = "/detailedInfo/{userID}")
    public CommonResult<UserInformation> queryUserDetailedInfo (@PathVariable("userID") String userID){
        return urs.getUserDetailedMsg(userID);
    }

    /**
     * 根据昵称获取用户列表
     * @return
     */
    @GetMapping(value = "/list/{nickName}")
    public CommonResult<List<UserInformation>> queryUserList(@PathVariable("nickName") String nickName){
        return urs.queryUserListService(nickName);
    }


}
